function city_choose(){
	$.post("/address/county",{
		id:$("#city").val()
	},
	function(result){    
		if(result!=""){ 
			if($('#city').find("option:selected").text()!="")
				$('#address').val($('#city').find("option:selected").text());
			$("#country").html(result);
		}
	}); 
}

function county_choose(){
	$.post("/address/street",{
		id:$("#country").val()
	},
	function(result){    
		if(result!=""){ 
			$('#address').val($('#city').find("option:selected").text()+$('#country').find("option:selected").text());
			$("#street").html(result);
		}
	}); 
}

function street_choose(){
	$('#address').val($('#city').find("option:selected").text()+$('#country').find("option:selected").text()+$('#street').find("option:selected").text());
}

function word_choose(id){
	if(id=='del'){
		var a=$('#address').val();
		$('#address').val(a.substring(0,a.length-1));
	}else{
		$('#address').val($('#address').val()+$('#'+id).val());
	}
}

function hous_ebuilding_word_choose(id){
	if(id=='del'){
		var a=$('#hous_ebuilding_address').val();
		$('#hous_ebuilding_address').val(a.substring(0,a.length-1));
	}else{

		//alert($('#'+id).val() +id);

		$('#hous_ebuilding_address').val($('#hous_ebuilding_address').val()+$('#'+id).val());

	}
}

function show_address(id){
	
	
	$("#city").val("1");
	$.post("/address/county",{
		id:$("#city").val()
	},
	function(result){    
		if(result!=""){ 
			$("#country").html(result);
		}
	});
	 
	$("#street").html("<option value=''>請選擇</option>");
	$('#address').val($('#'+id).val());
	$('#address_select').dialog({
		autoOpen: true,
		modal: true,
		width: 620,
		buttons: {
			"確定": function () {
				if($('#address').val()!="")
					$('#'+id).val($('#address').val());
				$(this).dialog("close");
			},
			"取消": function () {
				$(this).dialog("close");
			}
		}
	});

}


function hous_ebuilding_street_choose(){
	$('#hous_ebuilding_address').val($('#hous_ebuilding_street').find("option:selected").text());
}
function hous_ebuilding_administrative_area_choose(){
	$.post("/address/administrative_area",{
		id:$("#hous_ebuilding_administrative_area").val()
	},
	function(result){    
		if(result!=""){ 
			$("#hous_ebuilding_street").html(result);
		}
	}); 
}

//物件輸入－建物門牌－行政區－第二個欄位

function show_hous_ebuilding(id){

    
        /*
	$("#hous_ebuilding_administrative_area").val($("#administrative_area").val());
	$.post("/address/administrative_area",{
		id:$("#hous_ebuilding_administrative_area").val()
	},
	function(result){    
		if(result!=""){ 
			$("#hous_ebuilding_street").html(result);
		}
	}); 
        */
       
	$('#hous_ebuilding_select').dialog({
		autoOpen: true,
		modal: true,
		width: 600,
		buttons: {
			"確定": function () {
                            
				//$("#administrative_area").val($("#hous_ebuilding_administrative_area").find("option:selected").text());
				if($('#hous_ebuilding_address').val()!="")
					$('#'+id).val($('#hous_ebuilding_address').val());
				$(this).dialog("close");
			},
			"取消": function () {
				$(this).dialog("close");
			}
		}
	});

}